package org.thanos.iot.dao.graphic;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import org.thanos.iot.entity.graphic.GraphicComponentFile;

import java.util.List;

public interface GraphicComponentFileMapper {


    List<GraphicComponentFile> selectComponentFile(@Param("graphicComponentId") Integer graphicComponentId);

    List<Integer> selectComponentFileIds();

    GraphicComponentFile selectPathByComponentId(@Param("graphicComponentId") Integer graphicComponentId);

    List<GraphicComponentFileWithPathVo> selectComponentFilesByComponentId(@NotNull @Param("graphicComponentId") Integer graphicComponentId);

    @Results({
            @Result(column = "path", property = "path", jdbcType = JdbcType.VARCHAR)
    })
    @Select("SELECT path FROM iot_graphic_component_file left join iot_graphic_file ON iot_graphic_component_file.graphic_file_id = iot_graphic_file.id WHERE graphic_component_id = #{graphicComponentId}")
    List<String> selectComponentFilePathByComponentId(@Param("graphicComponentId") Integer graphicComponentId);

    int insertComponentFiles(@Param("graphicComponentFiles") List<GraphicComponentFile> graphicComponentFiles);

    int deleteComponentFilesByComponentId(@Param("graphicComponentId") Integer graphicComponentId);

    int deleteComponentFilesByComponentIds(@Param("list") List<Integer> componentIds);
}
